<template>
  <div class="box">
    <van-nav-bar title="演出详情">
      <template #left @click="goBack">
        <van-icon name="arrow-left" @click="goBack" />
      </template>
      <template #right>
        <van-icon name="wap-home-o" @click="goHome" />
      </template>
    </van-nav-bar>
    <div class="detail_main">
      <div class="detail_main_pic">
        <img :src="detailList.pic" alt="">
      </div>
      <div class="detail_main_text">
        <p>{{detailList.name}}</p>
        <span>￥{{detailList.min_price}}</span>
      </div>
    </div>
    <div class="detail_desc">
      <div class="detail_desc_box">
        <van-icon name="checked" />
        <span>{{detailList.support_desc}}</span>
      </div>
    </div>
    <div class="detail_data">
      <div class="detail_data_time">
        <span v-if="detailList.start_show_time">{{detailList.start_show_time.substring(0,10)}}</span>&nbsp;&nbsp;
        <span v-if="detailList.start_show_time">{{detailList.show_time_bottom + detailList.start_show_time.substring(11,16)}}</span>
      </div>
      <div class="detail_data_address">
        {{detailList.city_name}} | {{detailList.venue_name}}
      </div>
      <div class="detail_data_vip" @click="goVip">
        <span>橙PLUS卡</span>
        <span>开通送¥100 最高省138.8元</span>
        <van-icon name="arrow" />
        <span>立即开卡</span>
      </div>
    </div>
    <div class="detail_vip">
      <div>
        <span>VIP+：</span>
        <p>V+会员享  <b>国内免邮 + 双倍积分</b></p>
        <van-icon name="arrow" class="icon"  @click="goVip" />
      </div>
      <div>
        <span>入&nbsp;&nbsp;场：</span>
        <p>儿童一律凭票入场</p>
      </div>
    </div>
    <div class="detail_hint" @click="warm_prompt">
      <div>
        <span>温馨提示</span>
        <van-icon name="arrow" class="icon1" />
      </div>
      <ul>
        <li>● 配送说明</li>
        <li>● 订票说明</li>
        <li>● 确认订单</li>
        <li>● 购票提醒</li>
      </ul>
    </div>
    <van-action-sheet v-model="show" title="温馨提醒" class="detail_content">
      <div class="text">
        <div>
          <span>●</span>
          <span>配送说明</span>
        </div>
        <p>本演出不支持修改配送方式及配送信息服务，请务必于下单前检查并确认好收货信息。为避免快递不能及时送达，距本演出开场时间少于3天，不提供快递配送服务，您可以选择电子票或者演出现场取票（电子票不提供纸质票品，电子票与现场取票均不支持变更收货人信息）</p>
      </div>
      <div class="text">
        <div>
          <span>●</span>
          <span>订票说明</span>
        </div>
        <p>网上订购请提前选择您意欲购买的演出和票品价位，根据流程提示完成订票</p>
      </div>
      <div class="text">
        <div>
          <span>●</span>
          <span>确认订单</span>
        </div>
        <p>下单成功后，您可以通过微信公号【聚橙票务】-【个人中心】-【我的订单】查看订单详情。如有任何疑问，请致电客服热线：400-185-8666咨询</p>
      </div>
      <div class="text">
        <div>
          <span>●</span>
          <span>购票提醒</span>
        </div>
        <p>因票品的特殊性，一经订购，不退不换，请订票前务必确认购买意向</p>
      </div>
    </van-action-sheet>
    <div class="detail_footer">
      <van-icon name="service" class="icon2" @click="chat" />
      <button @click="goBuy">立即购买</button>
    </div>
    <van-action-sheet v-model="show1" class="detail_buy">
      <div class="text">
        <van-icon name="cross" class="closeIcon" @click="closeShow1" />
        <div class="nav">
          <h3>选择日期</h3>
          <span v-if="detailList.start_show_time">{{detailList.start_show_time.substring(0,10)}}&nbsp;{{detailList.show_time_bottom}}</span>
        </div>
        <div class="nav">
          <h3>选择场次</h3>
          <span v-if="detailList.start_show_time">{{detailList.start_show_time.substring(11,16)}}</span>
        </div>
        <div class="nav">
          <h3>选择价格</h3>
          <span>{{detailList.min_price}}元</span>
        </div>
        <div class="nav">
          <h3>购买数量</h3>
          <van-stepper v-model="num" />
        </div>
        <div class="button">
          <button @click="goCart">选座购买({{num}})</button>
        </div>
      </div>
    </van-action-sheet>
  </div>
</template>

<script>
import Vue from 'vue'
import { Icon, NavBar, ActionSheet, Stepper, Toast } from 'vant'
import { getDetailList, getCart } from '@/api'
Vue.use(NavBar)
Vue.use(Icon)
Vue.use(ActionSheet)
Vue.use(Stepper)
Vue.use(Toast)
export default {
  data () {
    return {
      proid: '',
      detailList: [],
      show: false,
      show1: false,
      num: 1
    }
  },
  mounted () {
    this.proid = this.$route.query.proid
    getDetailList({ proid: this.proid }).then(res => {
      this.detailList = res.data.data
      // console.log(this.detailList)
    })
    // 解决路由传参跳转不在头部问题！！
    this.$router.afterEach(() => {
      window.scrollTo(0, 0)
    })
  },
  methods: {
    chat () {
      // console.log('chat...')
      window._MEIQIA('withoutBtn')
      window._MEIQIA('init')
      window._MEIQIA('allSet', function () {
        window._MEIQIA('showPanel')
        // 先从服务器获取可以传递的用户信息，执行以下步骤 获取用户信息
        window._MEIQIA('metadata', {
          name: 'juooo',
          tel: '120000000',
          email: '12000000@qq.com',
          qq: 12000000,
          age: 12
        })
      })
    },
    goBack () {
      this.$router.go(-1)
    },
    closeShow1 () {
      this.show1 = false
    },
    goHome () {
      this.$router.push('/home')
    },
    goVip () {
      this.$router.push('/vip')
    },
    warm_prompt () {
      this.show = true
    },
    goBuy () {
      this.show1 = true
    },
    goCart () {
      if (localStorage.getItem('loginState') !== 'ok') {
        this.$router.push('/login')
      } else {
        getCart({
          userid: localStorage.getItem('userid'),
          proid: this.proid,
          num: this.num
        }).then(res => {
          Toast('即将跳转购物车页')
          setTimeout(() => {
            this.$router.push({ path: '/cart', query: { proid: this.proid, num: this.num } })
          }, 1000)
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.detail_main {
  width: 100%;
  height: 1.73rem;
  box-sizing: border-box;
  padding: 0 0.15rem;
  .detail_main_pic {
    width: 30%;
    height: 1.43rem;
    margin-top: 0.15rem;
    float: left;
    border-radius: 0.03rem;
    overflow: hidden;
    img {
      width: 100;
      height: 100%;
    }
  }
  .detail_main_text {
    margin: 0.22rem 0 0 0.14rem;
    float: left;
    width: 65%;
    height: 1.35rem;
    p {
      width: 100%;
      height: auto;
      line-height: 0.2rem;
      font-size: 0.16rem;
      color: black;
      margin-bottom: 0.7rem;
    }
    span {
      width: 100%;
      height: 0.2rem;
      line-height: 0.2rem;
      font-size: 0.2rem;
      font-weight: bold;
    }
  }
}
.detail_desc {
  width: 100%;
  height: 0.41rem;
  box-sizing: border-box;
  padding: 0 0.15rem;
  line-height: 0.41rem;
  .detail_desc_box {
    width: 100%;
    height: 100%;
  border-bottom: 1px solid #EBEBEB;
  }
  span {
    padding-left: 0.05rem;
    color: #666666;
    font-size: 0.12rem;
  }
}
.detail_data{
  width: 100%;
  box-sizing: border-box;
  padding: 0.18rem 0.15rem 0.16rem 0.15rem;
  height: 1.5rem;
  .detail_data_time {
    width: 100%;
    height: 0.16rem;
    line-height: 0.16rem;
    color: #232323;
    span:nth-of-type(1) {
      font-size: 0.16rem;
    }
    span:nth-of-type(2) {
      font-size: 0.12rem;
    }
  }
  .detail_data_address {
    width: 100%;
    height: 0.2rem;
    line-height: 0.2rem;
    color: #232323;
    font-size: 0.14rem;
    margin-top: 0.15rem;
    margin-bottom: 0.2rem;
  }
  .detail_data_vip {
    width: 100%;
    height: 0.44rem;
    line-height: 0.44rem;
    background-image: linear-gradient(-4deg, #1e1e1e, #464542);
    border-radius: 0.04rem;
    overflow: hidden;
    span:nth-of-type(1) {
      width: 0.65rem;
      height: 0.18rem;
      background-image: linear-gradient(0deg, #f5dea9, #f8d583);
      margin-left: 0.1rem;
      font-size: 0.12rem;
      line-height: 0.18rem;
      text-align: center;
      float: left;
      margin-top: 0.13rem;
    }
    span:nth-of-type(2) {
      width: 1.85rem;
      height: 0.18rem;
      line-height: 0.18rem;
      color: #f5dea9;
      font-size: 0.14rem;
      float: left;
      margin-top: 0.13rem;
      margin-left: 0.1rem;
    }
    span:nth-of-type(3) {
      width: 0.5rem;
      height: 0.18rem;
      line-height: 0.18rem;
      color: #f5dea9;
      font-size: 0.12rem;
      float: right;
      margin-top: 0.13rem;
    }
  }
}
.detail_vip {
  width: 100%;
  padding: 0 0.15rem;
  height: 1.14rem;
  box-sizing: border-box;
  border-top: 0.12rem solid #eeeeee;
  border-bottom: 0.12rem solid #eeeeee;
  div {
    width: 100%;
    height: 0.45rem;
    border-bottom: 1px solid #ebebeb;
    line-height: 0.45rem;
    color: #999999;
    span {
      float: left;
    }
    p {
      float: left;
      margin-left: 0.1rem;
      font-size: 0.12rem;
      color: #222222;
      b {
        font-weight: normal;
        color: #ff6743;
      }
    }
    .icon {
      color: #666666;
      font-size: 0.12rem;
      float: right;
    }
  }
}
.detail_hint {
  width: 100%;
  height: 0.9rem;
  padding: 0.2rem 0.15rem 0 0.15rem;
  box-sizing: border-box;
  margin-bottom: 0.55rem;
  div {
    width: 100%;
    height: 0.18rem;
    line-height: 0.18rem;
    span {
      float: left;
      color: #232323;
      font-size: 0.16rem;
      font-weight: bold;
    }
    .icon1 {
      float: right;
      margin-top: 0;
      color: #232323;
      font-size: 0.16rem;
    }
  }
  ul {
    margin-top: 0.16rem;
    li {
      float: left;
      color: #999999;
      text-align: left;
      width: 25%;
      font-size: 0.12rem;
    }
  }
}
.detail_footer {
  width: 100%;
  height: 0.55rem;
  position: fixed;
  bottom: 0;
  z-index: 100;
  border-top: 1px solid #ebebeb;
  .icon2 {
    float: left;
    font-size: 0.28rem;
    margin-left: 0.12rem;
    line-height: 0.55rem;
  }
  button {
    width: 80%;
    height: 0.4rem;
    margin-right: 0.12rem;
    float: right;
    background-image: linear-gradient(50deg, #ff9a34, #ff4d4a);
    border-radius: 0.2rem;
    border: none;
    font-size: 0.16rem;
    line-height: 0.4rem;
    color: white;
    font-weight: bold;
    margin-top: 0.07rem;
  }
}
.detail_content {
  width: 100%;
  height: 4.6rem;
  .text {
    div {
      width: 100%;
      height: 0.14rem;
      margin-top: 0.2rem;
      padding-left: 0.15rem;
      box-sizing: border-box;
      span {
        line-height: 0.14rem;
        float: left;
      }
      span:nth-of-type(1) {
        color: #999999;
        font-size: 0.1rem;
      }
      span:nth-of-type(2) {
        color: #000000;
        margin-left: 0.1rem;
        font-size: 0.14rem;
      }
    }
    p {
      width: 100%;
      height: auto;
      padding: 0.1rem 0.15rem 0 0.3rem;
      box-sizing: border-box;
      font-size: 0.12rem;
      color: #666666;
      line-height: 0.16rem;
    }
  }
}
.detail_buy {
  width: 100%;
  height: 4.6rem;
  .text {
    .nav:nth-of-type(1) {
      span {
        width: 1.38rem;
      }
    }
    .closeIcon {
      float: right;
      margin-right: 0.15rem;
      line-height: 0.40rem;
      font-size: 0.2rem;
    }
    .nav {
      width: 3.6rem;
      height: auto;
      margin: 0.2rem 0 0 0.15rem;
      overflow: hidden;
      h3 {
        width: 100%;
        height: 0.2rem;
        line-height: 0.2rem;
        float: left;
      }
      span {
        width: 1.07rem;
        height: 0.4rem;
        margin: 0.12rem 0.1rem 0 0;
        float: left;
        background: rgba(255,103,67,0.08);
        color: #ff6743;
        line-height: 0.4rem;
        text-align: center;
        border-radius: 0.05rem;
      }
    }
    .button {
      position: fixed;
      bottom: 0;
      width: 100%;
      height: 0.55rem;
      border-top: 1px solid #ebebeb;
      button {
        margin: 0.07rem 0.12rem;
        width: calc(100% - 0.24rem);
        height: 0.4rem;
        border-radius: 0.2rem;
        border: none;
        background: linear-gradient(-50deg, #ff4d4a 0%, #ff9a34 100%),linear-gradient(#fefefe, #fefefe);
      }
    }
  }
}
/deep/ .van-icon-arrow-left {
  color: black;
  font-size: 0.2rem;
}
/deep/ .van-nav-bar__title {
  color: black;
  font-size: 0.18rem;
  font-weight: bold;
}
/deep/ .van-icon-wap-home-o {
  color: black;
  font-size: 0.2rem;
}
/deep/ .van-icon-checked {
  font-size: 0.12rem;
  color: #FF6743;
}
/deep/ .van-icon-arrow {
  font-size: 0.14rem;
  color: #f5dea9;
  margin-top: 0.16rem;
  float: right;
}
/deep/ .van-popup--bottom.van-popup--round {
  border-radius: 0.1rem 0.1rem 0 0;
}
/deep/ .van-action-sheet__close {
  top: 0.24rem;
}
/deep/ .van-stepper {
  font-size: 0.3rem;
}
/deep/ .van-action-sheet__header {
  text-align: left;
  margin-left: 0.1rem;
  font-size: 0.2rem;
  font-weight: bold;
  height: 0.2rem;
  margin-top: 0.24rem;
  line-height: 0.2rem;
}
</style>
